package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 产前第一次随访第二页
 * 
 * 
 * @author sunping
 * 
 */
public class ChanQianVisitSecondActivity extends AbstractControlActivity
		implements OnClickListener {

	// 创建日期ID
	private String createDate;

	// 既往史
	private int[] jiWangShi = { R.id.check_jws_wu, R.id.check_jws_xinzangbing,
			R.id.check_jws_shenzangbing, R.id.check_jws_ganzangbing,
			R.id.check_jws_gaoxueya, R.id.check_jws_pinxue,
			R.id.check_jws_tangniaobing };

	// 家族史
	private int[] jiaZuShi = { R.id.check_jzs_yichuanbing,
			R.id.check_jzs_jingshenbing };

	// 个人史
	private int[] geRenShi = { R.id.check_grs_xiyan, R.id.check_grs_yinjiu,
			R.id.check_grs_fuyongyaowu, R.id.check_grs_youduwuzhi,
			R.id.check_grs_fangshewuzhi };

	// 孕产史
	private int[] yunChanshi = { R.id.check_ycs_liuchan, R.id.check_ycs_sitai,
			R.id.check_ycs_sichan, R.id.check_ycs_xinshengersw,
			R.id.check_ycs_chushengqxe };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_chanqian_visit_second);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addCheckBoxGroupView(jiWangShi, "既往史", R.id.edt_jws_qita, "其它既往史", "无");

		addCheckBoxView(jiaZuShi, "家族史");
		addEditTextView(R.id.edt_jzs_qita, "其它家族史");

		addCheckBoxView(geRenShi, "个人史");
		addEditTextView(R.id.edt_grs_qita, "其它个人史");

		addCheckBoxView(yunChanshi, "孕产史");

		addRadioGroupView(R.id.rad_fukeshoushu, "妇科手术史");

		addRadioEditUnionView(new int[] { R.id.edt_waiyin_ycsm }, "外阴",
				new String[] { "外阴异常" }, R.id.rad_waiyin, "有异常");

		addRadioEditUnionView(new int[] { R.id.edt_yindao_ycsm }, "阴道",
				new String[] { "阴道异常" }, R.id.rad_yindao, "有异常");

		addRadioEditUnionView(new int[] { R.id.edt_gongjing_ycsm }, "宫颈",
				new String[] { "宫颈异常" }, R.id.rad_gongjing, "有异常");

		addRadioEditUnionView(new int[] { R.id.edt_zigong_ycsm }, "子宫",
				new String[] { "子宫异常" }, R.id.rad_zigong, "有异常");

		addRadioEditUnionView(new int[] { R.id.edt_fujian_ycsm }, "附件",
				new String[] { "附件异常" }, R.id.rad_fujian, "有异常");

		// // Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(ChanQianVisitSecondActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			intent.setClass(this, ChanQianVisitFirstActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			controlManager.toProperties();
			intent.setClass(this, ChanQianVisitThirdActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}
}
